package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cheer.entity.OaIntegralDetailEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

/**
 * 积分明细
 *
 * @author cheer
 */
@Mapper
@Repository
public interface OaIntegralDetailDao extends BaseMapper<OaIntegralDetailEntity> {

    default Integer selectCountByType(Integer type) {
        return selectCount(new QueryWrapper<OaIntegralDetailEntity>()
                .eq("type", String.valueOf(type)));
    }

    default Integer selectCountByTypeAndItem(Integer type, Integer itemId) {
        return selectCount(new QueryWrapper<OaIntegralDetailEntity>()
                .eq("type", String.valueOf(type))
                .eq("items_id", String.valueOf(itemId)));
    }

    default Integer selectCountByTypeAndTime(Integer type, Integer startTime) {
        return selectCount(new QueryWrapper<OaIntegralDetailEntity>()
                .eq("type", String.valueOf(type))
                .ge("add_time", String.valueOf(startTime)));
    }
}
